package com.amos.muexamclient.config;

import com.amos.bean.Result;
import com.amos.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Copyright © 2018 嘉源锐信. All rights reserved.
 *
 * @Project: mu-exam
 * @ClassName: GlobalExceptionHandler
 * @Package: com.amos.muexamclient.config
 * @author: zhuqb
 * @Description:
 * @date: 2020/3/24 0024 下午 16:06
 * @Version: V1.0
 */
@Slf4j
@ControllerAdvice(basePackages = {"com.amos.muxamclient"})
@ResponseBody
public class GlobalExceptionHandler {
    /**
     * 处理自定义异常
     *
     * @param exception
     * @return
     */
    @ExceptionHandler(BaseException.class)
    public Result handleBizException(BaseException exception) {
        log.error("进入自定义异常拦截中...异常信息为:{}", exception.getMessage());
        return Result.error(exception.getMessage());
    }
}
